﻿using ImageMagick;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Photo.Core.Extensions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Claims;
using System.Threading.Tasks;

namespace Photo.Web.Core.Filters
{
    /// <summary>
    /// 去除入参 操作筛选器
    /// </summary>
    public class TrimInputActionFilter: IAsyncActionFilter
    {
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            var parameters = context.ActionArguments;//入参参数

            //去除前后空格
            if (parameters != null && parameters.Count > 0)
            {
                foreach (var param in parameters)
                {
                    parameters[param.Key] = param.Value.ToTrimString();
                }
            }

            await next();
        }
    }
}
